<?php
session_start();
?>

<?php
$id = $_SESSION['id'];


$scenario = $_REQUEST['new_scenario'];
$result =    $_REQUEST['new_result'];
$testcase =    $_REQUEST['new_testcase'];

//Checking if the Checklist for this CR is already filled..
$con = mysql_connect("localhost","root","");
mysql_select_db("checklist", $con);
$check = "select MAX(serial) from testcases where id = '$id' ";
$resource = mysql_query($check);
if($data = mysql_fetch_array($resource))
{
$count = $data['MAX(serial)'];
}

echo ''.$count;

$count++;

$sql = "insert into testcases(id , serial , testcase , scenario , result) values('$id','$count' , '$testcase' , '$scenario' , '$result')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

  //Adding javascript for redirection to welcome page after the data has been fed to database...
  
  echo '<script type="text/javascript">','alert("Test Case has Been Added Successfully!!");',
  'window.location = "http://172.26.195.159/checklist/php/mainpage.php";' ,'</script>';


?>